var archiving_message = false;
function user_mail_2archive(id,container,message){
  try{
  	archiving_message=container;
  	var url = getHost()+"user.user_mail_2archive/"+id+"?&execute=1";
  	aGet(url,"user_mail_archived");
    return false;
  }catch(e){
    alert("Error user_mail_2archive:"+e.message);
    return false;
  }
}

function user_mail_archived(content,xml){
  try{
    if(xml.responseText==''){
    	if(container=getElement(archiving_message)){
	      container.style.display="none";
  	  }
    	archiving_message=false;
    }else{
      alert(xml.responseText);
    }
  }catch(e){
    alert("Error user_mail_archived:"+e.message);
    return false;
  }
}

///////////////////// MARK AS READED
var reading_message = false;
function user_mail_2readed(id,container,message){
  try{
  	reading_message=id;
  	var url = getHost()+"user.user_mail_2readed/"+id+"?&execute=1";
  	aGet(url,"user_mail_readed");
    return false;
  }catch(e){
    alert("Error user_mail_2readed:"+e.message);
    return false;
  }
}

function user_mail_readed(content,xml){
  try{
    if(xml.responseText==''){
      if(reading_message){
      	var button=getElement("user_message_readed_"+reading_message);
      	if(button){
      		button.style.display="none";
      	}
    		reading_message=false;
    	}
    }else{
      alert(xml.responseText);
    	archiving_message=false;
    }
  }catch(e){
    alert("Error user_mail_readed:"+e.message);
    return false;
  }
}
// Display full message
function user_mail_full(object,id){
  try{
    var efull=getElement("user_message_full_"+id);
    var eshort=getElement("user_message_short_"+id);
    if(object.opened){
      efull.style.display="none";
      eshort.style.display="block";
      object.innerHTML="&darr;";
      object.opened=false;
    }else{
      efull.style.display="block";
      eshort.style.display="none";
      object.innerHTML="&uarr;";
      object.opened=true;
    }
  	return false;
  }catch(e){
    alert("Error user_mail_full:"+e.message);
    return false;
  }
}